home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / fht.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  2.2 KB  |  81 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_FHT_H
  19. #define f_FHT_H
  20.  
  21. // based on:
  22. //
  23. //------------------------------------
  24. //  fft.cpp
  25. //  The implementation of the 
  26. //  Fast Fourier Transform algorithm
  27. //  (c) Reliable Software, 1996
  28. //------------------------------------
  29. //
  30. // but now it's an FHT (Fast Hartley Transform)...
  31.  
  32. class Fht
  33. {
  34. public:
  35.     Fht (int Points, long sampleRate);
  36.     ~Fht ();
  37.     int     Points () const { return _Points; }
  38.     void    Transform (int width);
  39.     void    CopyInStereo8 (unsigned char *samples, int count);
  40.     void    CopyInMono8 (unsigned char *samples, int count);
  41.     void    CopyInStereo16 (signed short *samples, int count);
  42.     void    CopyInMono16 (signed short *samples, int count);
  43.  
  44.     double  GetIntensity (int i) const
  45.     { 
  46.         return R[i];
  47.     }
  48.  
  49.     int     GetFrequency (int point) const
  50.     {
  51.         // return frequency in Hz of a given point
  52.         long x =_sampleRate * point;
  53.         return x / _Points;
  54.     }
  55.  
  56.     int     HzToPoint (int freq) const 
  57.     { 
  58.         return (long)_Points * freq / _sampleRate; 
  59.     }
  60.  
  61.     int     MaxFreq() const { return _sampleRate; }
  62.  
  63.     int     Tape (int i) const
  64.     {
  65.         return (int) aTape[i];
  66.     }
  67.  
  68. private:
  69.     int            _Points;
  70.     long        _sampleRate;
  71.  
  72.     int            bits;
  73.  
  74.     float        *aTape;
  75.     float        *sinTab;
  76.     int            *bRevTab;
  77.     float        *A, *B, *R, *W;
  78. };
  79.  
  80. #endif
  81.